<template>
    <div id="en">
        <h3>@keyup.enter  →  监听键盘回车事件</h3>
        <input @keyup.enter="fn" v-model="username" type="text">
    </div>
</template>

<script>
    export default {
        name: "1-v-on-指令修饰",
        data() {
            return {
                username: ''
            }
        },
        methods: {
            fn (e) {
                // if (e.key === 'Enter') {
                //   console.log('键盘回车的时候触发', this.username)
                // }

                console.log('键盘回车的时候触发', this.username)
            }
        }
    }
</script>

<style scoped>

</style>